package 并发编程02.volatile关键字案例;



public class Volatile {

    public  int count=0;

    public  synchronized void increase(){
        count++;
    }

    public static void main(String[] args) throws InterruptedException {
        final Volatile v=new Volatile();
       for(int i=0;i<10000;i++){
           new Thread(){
            public void run(){
                v.increase();
            }
           }.start();
       }
       while(Thread.activeCount()>2){
           Thread.yield();
       }
        System.out.println(v.count);
    }
}
